/**
 * @author florian
 */

PictureManagAir.Window = Ext.extend(Ext.Window, {

    // configurables
    // anything what is here can be configured from outside
    layout: 'border'    // {{{
    ,
    initComponent: function(){
        // {{{
        Ext.apply(this, {
            items: [{
                xtype: 'linkspanel',
                region: 'west',
                width: 200,
                collapsible: true,
                collapseMode: 'mini',
                split: true
            }, {
                xtype: 'tabpanel',
                region: 'center',
                border: false,
                activeItem: 0,
                items: [{
                    title: 'A tab'
                }]
            }]
        }); // e/o apply
        // }}}
        
        // call parent
        PictureManagAir.Window.superclass.initComponent.apply(this, arguments);
        
        this.linksPanel = this.items.itemAt(0);
        this.tabPanel = this.items.itemAt(1);
        
        this.linksPanel.on({
            scope: this,
            render: function(){
                this.linksPanel.body.on({
                    scope: this,
                    click: this.onLinkClick,
                    delegate: 'a.PictureManagAirlink',
                    stopEvent: true
                });
            }
        });
    } // e/o function initComponent
    // }}}
    // {{{
    ,
    afterRender: function(){
    
        // call parent
        PictureManagAir.Window.superclass.afterRender.apply(this, arguments);
        
    } // e/o function afterRender
    // }}}
    
    ,
    onLinkClick: function(e, t){
        var title = t.innerHTML;
        var tab = this.tabPanel.items.find(function(i){
            return i.title === title;
        });
        if (!tab) {
            tab = this.tabPanel.add({
                title: title,
                layout: 'fit',
                activate: true
            });
        }
        this.tabPanel.setActiveTab(tab);
        
    } // eo function onLinkClick
}); // e/o extend
// register xtype
Ext.reg('PictureManagAirwindow', PictureManagAir.Window);
// }}}

